<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
	<c:set var="ctx" value="${pageContext.request.contextPath}" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>高风险管理</title>
	<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
    var grid = null;
    var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    $(function () {
        initTab();
        var _url = '<%=path%>/spl/splHRiskWarnRec/initList.do?' ;
        $("#ligergrid1").ligerGrid({
            url: _url,
            method : 'get',
            columns: [
                { display: '企业名称', align:'left', width: 200,
                    render: function (rowdata, rowindex, value){
                        return rowdata.dataNm;
                    }
                },
                { display: '属性', name: 'dataAttrCd',width: 60 ,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(value) && value==CustomerConstant.CST_TYPE_NP_CD){//1自然人 2法人
                            return "自然人";
                        }else if(StringUtils.isNotEmpty(value) && value==CustomerConstant.CST_TYPE_CORP_CD){
                            return "法人";
                        }else if(StringUtils.isNotEmpty(rowdata.dataTyp) && rowdata.dataTyp == 'LNK'){
                            return "挂靠公司";
                        } else {
                        	return "未知";
                        }
                    }
                },
                { display: '营业执照号/证件号', name: 'dataSucc', align:'left', width: 150 },
                { display: '审核状态', width: 80,name: 'audStsCd',
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(value)){
                            return rowdata.audStsCdNm ;
                        }else{
                            return '待提交';
                        }
                    }
                },
                { display: '预警状态', width: 150,name: '',
                    render: function (rowdata, rowindex, value){
                    	return '<font color="red"><i class="ico_flasher"></i>高风险预警</font>';
                    }
                },
                { display: '风险标记', minWidth: 150,isEllipsis: false,
                    render: function (rowdata, rowindex, value){
                    	return rowdata.opTypCdNm;
                    }
                },
				getOptColumns(),
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-2,
            checkbox:true,
            fixedCellHeight: false,
            rownumbers:true,
//			onAfterShowData: getFlowIds,
        });
        grid = liger.get("ligergrid1");
        //grid.setHeight(100);
        $("#searchBar").ligerForm();
        $('#reasonFromSet').ligerForm({
            validate : true
        });

        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            console.log(JSON.stringify(data));
            for (name in data){
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });
        $("#clearBtn").click(function(event) {
            //$("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "dataTyp": "SPL",
                "audStsCd": " ",
                "rgnProvCd": " ",
                "rgnCityCd": " ",
                "dataAttrCd": " ",
                "dataNm": " ",
            });
        });
    });

	function getOptColumns(){
		var col =  { display: '操作', width: 300 , align:'left',	isEllipsis: false,
			render: function (rowdata, rowindex, value){
				var opt = "";
				//审核
				var h='<a class="sq-button-hasicon" href="javascript:warnCheck(';
				h+="'"+rowdata.dataId+"'";
                h+=",'"+rowdata.audStsCd+"'";
                h+=",'"+rowdata.dataAttrCd+"'";
                h+=",'"+rowdata.dataTyp+"'";
                h+=",'"+rowdata.id+"'";
				h+=')"><i class="sqBtnIco_6"></i>审核</a>';
				opt += h;

				var opLogBtn = '<a class="sq-button-hasicon" href="javascript:searchOpLog(';
				opLogBtn += "'"+rowdata.dataId+"'";
				opLogBtn += ",'"+rowdata.dataTyp+"'";
				opLogBtn += ')"><i class="sqBtnIco_4"></i>操作日志</a>';
				opt += opLogBtn;

				//return end + bk;
				//return opt + SQ.dropLinks(end);
                return opt;
			}
		};
		return col;
	}

    var callback = function () {
        grid.reload();
    };

    //审核
    function warnCheck(_id,_audStsCd,_dataAttrCd, _dataTyp, _warnRecId){
        if(!_id)return;
        if(_dataTyp == "SPL"){
            //parent.mainApp.f_addTab('PrdSpl_3'+_id,'供应商详情','<%=path%>/product/splInfo/toDetailPage.do?id='+_id+'&splAttrCd='+_dataAttrCd+'&audStsCd='+_audStsCd + "&isWarnCheck=1&warnRecId=" + _warnRecId);
            Add_navTab('verify_spl_risk_warn' + _id, '高风险审核', '/product/splInfo/toDetailPage.do?id='+_id+'&splAttrCd='+_dataAttrCd+'&audStsCd='+_audStsCd + "&isWarnCheck=1&warnRecId=" + _warnRecId, callback);
        }else{
        	//parent.mainApp.f_addTab('tab_prj_lnk_comp_detail' + _id, '挂靠公司详情', '<%=path%>/project/prjlnkcomp/toDetailPage.do?id=' + _id + "&isWarnCheck=1&warnRecId=" + _warnRecId);
            Add_navTab('verify_lnk_risk_warn' + _id, '高风险审核', '/project/prjlnkcomp/toDetailPage.do?id=' + _id + "&isWarnCheck=1&warnRecId=" + _warnRecId, callback);
        }
    }

    // 操作日志
    function searchOpLog(_id, _dataTyp){
        console.log(_id);
        // 弹出框显示供应商历史操作记录
        $.ligerDialog.SQopen({
            width: 800,
            height:500,
            title : '操作日志',
            url:'<%=path%>/spl/splOpLogRec/toListPage.do?dataId='+_id+'&opObjTyp=' + _dataTyp,
        });
    }

    function iframeResize () {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        };
    }
    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    var loadedTabs = [];
    //初始化Tab页签
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function(tabid) {

            },
            onAfterSelectTabItem: function(tabid) {
            	var selectedRows = grid.getSelectedRows();
                loadedTabs = [];
                console.log(tabid);
                switch (tabid){
                    case "tabB":
                        console.log(tabid)
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/spl/splHRiskWarnRec/toFlowListPage.do?");
                        break;
                }
	
	            SetIframe_height();

            }
        });
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });

    };
</script>

<body class="iframeBody">
<div class="Wrapper">
	<div id="pageInTab" class="pageInTab">
		<div tabid="tabA" title="项目列表" lselected="true">
			<div class="searchArea">
				<form id="searchBar">
					<div class="fieldset1 clearFix">
						<div class="fieldBox">
							<div class="label">企业名称</div>
							<div class="field">
								<input name="dataNm" id="dataNm" type="text" class="ui-textbox" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">属性</div>
							<div class="field">
								<select name="dataAttrCd" id="dataAttrCd" data-value=" ">
									<option value=" " seleted>请选择</option>
									<c:forEach items="${splAttrCdList }" var="kv">
										<option value="${kv.key }">${kv.value }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">审核状态</div>
							<div class="field">
								<select name="audStsCd" id="audStsCd" data-value=" ">
									<option value=" " seleted>请选择</option>
									<c:forEach items="${searchAudStsCdList }" var="kv">
										<option value="${kv.key }">${kv.value }</option>
									</c:forEach>
									<option value="99">变更审核中</option>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">区域</div>
							<div class="field">
								<div class="field">
									<jsp:include page="../../system/sysRegion/region.jsp" flush="true" >
										<jsp:param name="regionShowLvl" value="2"/>
									</jsp:include>
								</div>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">企业类型</div>
							<div class="field">
								<select name="dataTyp" id="dataTyp" data-value=" ">
									<option value="SPL" seleted>供应商</option>
									<option value="LNK" >挂靠公司</option>
								</select>
							</div>
						</div>
						<div class="clearFix"></div>
						<div class="btnsBox formBtns notRight">
							<span id="searchBtn" class="sq-button-round">查询</span>
							<span id="clearBtn" class="sq-button-round">清空</span>
						</div>
					</div>
				</form>
			</div>
			
			<div class="sqPanel" style="margin-bottom: 0;">
				<div class="sqPanel_body">
					<div id="ligergrid1" class="sq-grid"></div>
				</div>
			</div>

		</div>
		<div tabid="tabB" title="复议列表" id="tabBId">
			<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
		</div>
	</div>
</div>

</body>
</html>